-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: make PodTemplateSpec more robust and less error prone #255
Draft
pmalek
wants to merge
6
commits into
main
Choose a base branch
from
strategic-merge-patch-revisited
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,582
−188
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pmalek
force-pushed
the
strategic-merge-patch-revisited
branch
from
May 10, 2024 13:01
ed2d367
to
3ec82f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about?
gateway-operator/controller/dataplane/owned_deployment.go
Lines 133 to 144 in 8ffc149
// TODO https://github.com/Kong/gateway-operator/issues/128 | |
// This is a a workaround to avoid patches clobbering the wrong EnvVar. We want to find an improved patch mechanism | |
// that doesn't clobber EnvVars (and other array fields) it shouldn't. | |
existingEnvVars := desiredDeployment.Spec.Template.Spec.Containers[0].Env | |
desiredDeployment.Spec.Template.Spec.Containers[0].Env = []corev1.EnvVar{} | |
// apply user patches and set any default environment variables that aren't already set | |
desiredDeployment, err = applyDeploymentUserPatchesForDataPlane(dataplane, desiredDeployment) | |
if err != nil { | |
return nil, op.Noop, err | |
} | |
// apply default envvars and restore the hacked-out ones | |
desiredDeployment = applyEnvForDataPlane(existingEnvVars, desiredDeployment) |
Moving this out of 1.4 as we have other priorities to complete for that milestone. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
This PR makes strategic merge patch more robust and less error prone by preventing several problematic use cases:
users needing to restate the base manifest (generated by KGO) which is not known to them before hand.
With this PR, this won't be necessary anymore as. Users won't need to provide elements form base manifests.
So this:
becomes:
using Go API users could experience merging mutually exclusive fields e.g. when setting env vars:
gateway-operator/pkg/utils/kubernetes/resources/strategicmerge_test.go
Lines 752 to 807 in 3876430
This PR fixes this as well. Users are not required anymore to restate the elements from the base manifest array as in e.g.
gateway-operator/pkg/utils/kubernetes/resources/strategicmerge_test.go
Lines 808 to 870 in 3876430
this PR additionally catches previously uncaught errors like setting not fully spec's readinessProbe on a sidecar:
gateway-operator/config/samples/dataplane-sidecar.yaml
Lines 44 to 46 in 36c58ab
This now properly yields an error and is not silenced:
Which issue this PR fixes
Related #128
Special notes for your reviewer:
Prior work: https://github.com/Kong/gateway-operator-archive/pull/1489/
PR Readiness Checklist:
Complete these before marking the PR as
ready to review
:CHANGELOG.md
release notes have been updated to reflect significant changes